using UnityEngine;
using UnityEngine.EventSystems;

namespace MaterialUI
{
	[AddComponentMenu("MaterialUI/Dialogs/Time Picker Clock", 100)]
	public class DialogTimePickerClock : MonoBehaviour, IDragHandler, IPointerClickHandler, IEventSystemHandler
	{
		[SerializeField]
		private DialogTimePicker m_TimePicker;

		private Vector2 m_ClockPosition;

		private void Start()
		{
			Init();
		}

		public void Init()
		{
			Vector3 position = base.transform.position;
			float x = position.x;
			Vector3 position2 = base.transform.position;
			m_ClockPosition = new Vector2(x, position2.y);
		}

		public void OnDrag(PointerEventData eventData)
		{
			handleData(eventData);
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			handleData(eventData);
		}

		private void handleData(PointerEventData eventData)
		{
			Vector2 vector = eventData.position - m_ClockPosition;
			float num = 57.29578f * Mathf.Atan(vector.y / vector.x);
			if (vector.x < 0f)
			{
				num += 180f;
			}
			m_TimePicker.SetAngle(num);
		}
	}
}
